<template>
	<view>
		<view class='newsList'>
			<view class='swiper' v-if="imgUrls.length > 0">
				<swiper indicator-dots="true" :autoplay="autoplay" :circular="circular" :interval="interval"
					:duration="duration" indicator-color="rgba(102,102,102,0.3)" indicator-active-color="#666">
					<block v-for="(item,index) in imgUrls" :key="index">
						<swiper-item>
							<navigator :url="'/pages/news_details/index?id='+item.id">
								<image :src="item.imageInput" class="slide-image" />
							</navigator>
						</swiper-item>
					</block>
				</swiper>
			</view>
			<!-- 	<view class='nav' v-if="navList.length > 0">
				<scroll-view class="scroll-view_x" scroll-x scroll-with-animation :scroll-left="scrollLeft" style="width:auto;overflow:hidden;">
					<block v-for="(item,index) in navList" :key="index">
						<view class='item borRadius14' :class='active==item.id?"on":""' @click='tabSelect(item.id, index)'>
							<view>{{item.name}}</view>
							<view class='line bg-color' v-if="active==item.id"></view>
						</view>
					</block>
				</scroll-view>
			</view> -->
			<view class="msg">

				<uni-collapse border="true" v-for="(item,index) in articleList" :key="index"
					@change="changeZt($event,item)">
					<uni-collapse-item :disabled='item.disabled'>
						<template v-slot:title>

							<view class="msg-title">
								{{item.createTime}}
								<text style="margin-left: 30rpx;" v-if="item.isShowTit">{{item.content}}</text>

							</view>
						</template>
						<view class="content" @click="goPage(item.url)">
							{{item.content}}
						</view>
					</uni-collapse-item>

				</uni-collapse>
			</view>

		</view>
		<view class='noCommodity' v-if="articleList.length == 0 && (page != 1 || active== 0)">
			<view class='pictrue' style="text-align: center;">
				<image src="https://gfry.oss-cn-hangzhou.aliyuncs.com/crmebimage/public/content/2024/03/07/icon_nodata.png" mode=""></image>
				暂无数据

			</view>
		</view>
		<home></home>
	</view>
</template>

<script>

	import {
		getUserMessage,
		getUserMessageStatus
	} from '@/api/togeterRich/index.js'

	import home from '@/components/home';
	export default {
		components: {
			home
		},
		data() {
			return {
				list: [],
				height: '120rpx',
				isExpandedRate: false,
				imgUrls: [],
				articleList: [],
				indicatorDots: false,
				circular: true,
				autoplay: true,
				interval: 3000,
				duration: 500,
				navList: [],
				active: 0,
				page: 1,
				limit: 8,
				status: false,
				scrollLeft: 0
			};
		},
		/**
		 * 生命周期函数--监听页面显示
		 */
		onLoad() {
			// this.getArticleHot();
			// this.getArticleBanner();
			// this.getArticleCate();
			// this.status = false;
			this.page = 1;
			this.articleList = [];
			this.getCidArticle();
		},
		/**
		 * 页面上拉触底事件的处理函数
		 */
		onReachBottom: function() {
			this.getCidArticle();
		},
		methods: {
			goPage(url) {

				uni.navigateTo({
					url

				})
			},

			changeZt(e, item) {
				console.log(item, 'zheshisha ')
				// item.isShowTit = false

				if (e[0] == 0) {
					if (item.status == 0) {
						getUserMessageStatus(item.id).then(res => {
							console.log(res, 'dddsdsawef ')
						})
					}
					this.$set(item, 'isShowTit', false)
				} else {
					this.$set(item, 'isShowTit', true)
				}
				this.$forceUpdate()
				// console.log(e, 'eee')
				// console.log(item, 'jjnj')
			},
			toggleListRate() {

				this.isExpandedRate = !this.isExpandedRate; // 切换展开/收起状态
				if (this.isExpandedRate == true) {
					this.height = "100%"
				} else {
					this.height = "120rpx"
				}
			},
			getArticleHot: function() {
				let that = this;
				getUserMessage().then(res => {

					that.$set(that, 'articleList', res.data.list);
				});
			},

			getCidArticle: function() {
				console.log("zopunik")
				let that = this;
				// if (that.active == 0) return;
				let limit = that.limit;
				let page = that.page;
				let articleList = that.articleList;
				// if (that.status) return;

				getUserMessage(that.active, {
					page: page,
					limit: limit
				}).then(res => {
					let articleListNew = [];
					let len = res.data.length;
					articleListNew = articleList.concat(res.data);
					that.page++;
					that.$set(that, 'articleList', articleListNew);
					that.status = limit > len;
					that.page = that.page;
					res.data.map(eee => {
						eee.isShowTit = true
						eee.disabled = true
						console.log(eee, 'ewee')
						console.log(eee.content.length, 'eee.content.length')
						if (eee.content.length > 11) {
							eee.disabled = false
						}

					})
					console.log(this.articleList, 'articleListarticleList')
				});
			},

			tabSelect(active, e) {
				this.active = active;
				this.scrollLeft = e * 60;
				// this.scrollLeft = (active - 1) * 50;
				if (this.active == 0) this.getArticleHot();
				else {
					this.$set(this, 'articleList', []);
					this.page = 1;
					this.status = false;
					this.getCidArticle();
				}
			}
		}
	}
</script>

<style lang="scss">
	.msg {
		padding: 30rpx 50rpx;

		.content {
			padding: 30rpx 0;
		}

		.msg-title {
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
			padding: 25rpx 0;

		}
	}

	page {
		background-color: #fff !important;
	}

	.newsList .swiper {
		width: 100%;
		position: relative;
		box-sizing: border-box;
		padding: 0 30rpx;
	}

	.newsList .swiper swiper {
		width: 100%;
		height: 365rpx;
		position: relative;
	}

	.newsList .swiper .slide-image {
		width: 100%;
		height: 335rpx;
		border-radius: 14rpx;
	}

	// #ifdef MP-WEIXIN
	.newsList .swiper .wx-swiper-dot {
		width: 12rpx !important;
		height: 12rpx !important;
		border-radius: 0;
		transform: rotate(-45deg);
		transform-origin: 0 100%;
	}

	.newsList .swiper .wx-swiper-dot~.wx-swiper-dot {
		margin-left: 5rpx;
	}

	.newsList .swiper .wx-swiper-dots.wx-swiper-dots-horizontal {
		margin-bottom: -15rpx;
	}

	// #endif
	.newsList .swiper .uni-swiper-dot {
		width: 12rpx !important;
		height: 12rpx !important;
		border-radius: 0;
		transform: rotate(-45deg);
		transform-origin: 0 100%;
	}

	.newsList .swiper .uni-swiper-dot~.uni-swiper-dot {
		margin-left: 5rpx;
	}

	.newsList .swiper .uni-swiper-dots.uni-swiper-dots-horizontal {
		margin-bottom: -15rpx;
	}

	.newsList .nav {
		padding: 0 24rpx;
		width: 100%;
		white-space: nowrap;
		box-sizing: border-box;
		margin-top: 43rpx;
	}

	.newsList .nav .item {
		display: inline-block;
		font-size: 32rpx;
		color: #999;
	}

	.newsList .nav .item.on {
		color: #282828;
	}

	.newsList .nav .item~.item {
		margin-left: 46rpx;
	}

	.newsList .nav .item .line {
		width: 24rpx;
		height: 4rpx;
		border-radius: 2rpx;
		margin: 10rpx auto 0 auto;
	}

	.newsList .list .item {
		margin: 0 24rpx;
		border-bottom: 1rpx solid #f0f0f0;
		padding: 35rpx 0;
	}

	.newsList .list .item .pictrue {
		width: 250rpx;
		// height: 156rpx;
	}

	.newsList .list .item .pictrue image {
		width: 100%;
		height: 100%;
		border-radius: 14rpx;
	}

	.newsList .list .item .text {
		width: 100%;
		height: 100%;
		font-size: 24rpx;
		color: #999;
	}

	.newsList .list .item .text .name {
		font-size: 30rpx;
		color: #282828;
		overflow: hidden;
	}

	.newsList .list .item .picList .pictrue {
		width: 335rpx;
		height: 210rpx;
		margin-top: 30rpx;
	}

	.newsList .list .item .picList.on .pictrue {
		width: 217rpx;
		height: 136rpx;
	}

	.newsList .list .item .picList .pictrue image {
		width: 100%;
		height: 100%;
		border-radius: 6rpx;
	}

	.newsList .list .item .time {
		text-align: right;
		font-size: 24rpx;
		color: #999;
		margin-top: 22rpx;
	}
</style>